{extend name="public/base" /}
{block name="content"}
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-home"></i>&nbsp;卡密管理
            </li>
            <li>卡密添加</li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12">
                <div class="widget radius-bordered">
                    <div class="widget-header bordered-bottom bordered-themeprimary">
                        <span class="widget-caption">卡密添加</span>
                    </div>
                    <div class="widget-body">
                        <form action="" class="form-horizontal">

                            <div class="form-group">
                                <label for="cardnumber" class="control-label col-sm-2 no-padding-right">卡密数量</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="cardnumber" name="cardnumber" placeholder="卡密数量" />
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label for="cardtype_id" class="control-label col-sm-2 no-padding-right">对应卡密类型</label>
                                <div class="col-sm-6">
                                    <select id="cardtype_id" name="cardtype_id" class="form-control">
                                        {volist name="cardtypes" id="vo"}
                                        <option value="{$vo.id}">{$vo.cardtypename}</option>
                                        {/volist}
                                    </select>
                                    <span class="help-block">对应卡密的类型</span>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-6">
                                    <button class="btn btn-primary" id="cardAdd">添加</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /Page Body -->
</div>
{/block}
{block name="js"}
{__block__}
<script src="/static/lib/ueditor/ueditor.config.js"></script>
<script src="/static/lib/ueditor/ueditor.all.js"></script>
<script>
    $(function(){
        UE.getEditor('content');

        $('#cardAdd').click(function () {
            $.ajax({
                url:"{:url('admin/card/cardadd')}",
                type:'post',
                data:$('form').serialize(),
                dataType:'json',
                success:function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {
                            icon:6,
                            time:2000
                        }, function () {
                            location.href = data.url;
                        });
                    }else {
                        layer.open({
                            title:'文章添加失败',
                            content:data.msg,
                            icon:5,
                            anim:6
                        });
                    }
                }
            });
            return false;
        });
});
</script>
{/block}